home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / devices / src / createiorequest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-16  |  1.8 KB  |  84 lines

  1. /*
  2.     (C) 1995, 96 AROS - The Amiga Replacement OS
  3.     $Id$
  4.     $Log$
  5.     Desc:
  6.     Lang: english
  7. */
  8. #include "exec_intern.h"
  9. #include <exec/io.h>
  10. #include <exec/ports.h>
  11. #include <exec/memory.h>
  12. #include <aros/libcall.h>
  13.  
  14. /*****************************************************************************
  15.  
  16.     NAME */
  17.     #include <clib/exec_protos.h>
  18.  
  19.     __AROS_LH2(struct IORequest *, CreateIORequest,
  20.  
  21. /*  SYNOPSIS */
  22.     __AROS_LA(struct MsgPort *, ioReplyPort, A0),
  23.     __AROS_LA(ULONG,            size,        D0),
  24.  
  25. /*  LOCATION */
  26.     struct ExecBase *, SysBase, 109, Exec)
  27.  
  28. /*  FUNCTION
  29.     Create an I/O request structure bound to a given messageport.
  30.     I/O requests are normally used to communicate with exec devices
  31.     but can be used as normal messages just as well.
  32.  
  33.     INPUTS
  34.     ioReplyPort - Pointer to that one of your messageports where
  35.               the messages are replied to. A NULL port is legal
  36.               but then the function fails always.
  37.     size        - Size of the message structure including the struct
  38.               IORequest header. The minimal allowable size is that
  39.               of a struct Message.
  40.  
  41.     RESULT
  42.     Pointer to a new I/O request structure or NULL if the function
  43.     failed.
  44.  
  45.     NOTES
  46.  
  47.     EXAMPLE
  48.  
  49.     BUGS
  50.  
  51.     SEE ALSO
  52.  
  53.     INTERNALS
  54.  
  55.     HISTORY
  56.  
  57. ******************************************************************************/
  58. {
  59.     __AROS_FUNC_INIT
  60.  
  61.     struct IORequest *ret=NULL;
  62.  
  63.     /* A NULL ioReplyPort is legal but has no effect */
  64.     if(ioReplyPort==NULL)
  65.     return NULL;
  66.  
  67.     /* Allocate the memory */
  68.     ret=(struct IORequest *)AllocMem(size,MEMF_PUBLIC|MEMF_CLEAR);
  69.  
  70.     if(ret!=NULL)
  71.     {
  72.     /* Initialize it. */
  73.     ret->io_Message.mn_ReplyPort=ioReplyPort;
  74.  
  75.     /* This size is needed to free the memory at DeleteIORequest() time. */
  76.     ret->io_Message.mn_Length=size;
  77.     }
  78.  
  79.     /* All done. */
  80.     return ret;
  81.     __AROS_FUNC_EXIT
  82. } /* CreateIORequest */
  83.  
  84.